//
//  OEPakageHomeViewController.m
//  OneEightyNine
//
//  Created by Mac on 2019/3/4.
//  Copyright © 2019 stoneobs. All rights reserved.
//

#import "OEPakageHomeViewController.h"
#import "OETransactionDetailViewController.h"
#import "OERechargeDepositViewController.h"
#import "OERechargeViewController.h"
#import "OEBankListViewController.h"
@interface OEPakageHomeViewController ()
@property(nonatomic, strong) STLabel                     *moneyLable;/**<  */
@property(nonatomic, strong) NSString                     *money;/**< <##> */
@end

@implementation OEPakageHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configSubView];
    [self st_setRightItemWithTitle:OESTRING(@"TRANSACTION DETAILS") titleColor:SecendTextColor];
    // Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    self.moneyLable.text = [NSString stringWithFormat:@"$%@",STUserManger.defult.loginedUser.user_money];
    [OEUserDataController sendFetchMoneyRequest:^(NSString * _Nonnull money) {
        self.moneyLable.text = [NSString stringWithFormat:@"$%@",money];
        self.money = money;
    }];
}
#pragma mark --subView
- (void)configSubView{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 110)];
    header.backgroundColor = UIColor.whiteColor;
    self.tableView.backgroundColor = UIColor.whiteColor;
    __weak typeof(self) weakSelf =  self;
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(10, 30, UIScreenWidth - 20, 40)
                                                     text:OESTRING(@"MY SUBSCRIPTION")
                                                textColor:UIColor.blackColor
                                                     font:18
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [header addSubview:titleLable];
    
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, titleLable.bottom + 20, UIScreenWidth - 40, 130)];
    imageView.image = [UIImage imageNamed:@"750×320背景"];
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    imageView.backgroundColor = UIColor.whiteColor;
    [header addSubview:imageView];
    imageView.userInteractionEnabled = YES;
    imageView.layer.cornerRadius = 4;
    imageView.clipsToBounds = YES;
    [imageView st_showRoundLayer];
    
    STLabel * stitleLable = [[STLabel alloc] initWithFrame:CGRectMake(10, 15, UIScreenWidth - 20, 40)
                                                     text:OESTRING(@"DEPOSIT BALANCE")
                                                textColor:UIColor.blackColor
                                                     font:18
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [imageView addSubview:stitleLable];
    
    
    STLabel * moneyLable = [[STLabel alloc] initWithFrame:CGRectMake(10, stitleLable.bottom + 20, UIScreenWidth - 20, 40)
                                                      text:OESTRING(@"$")
                                                 textColor:SecendTextColor
                                                      font:14
                                               isSizetoFit:NO
                                             textAlignment:NSTextAlignmentLeft];
    [imageView addSubview:moneyLable];
    self.moneyLable = moneyLable;
    
    STButton * rechageButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 130, 36)
                                                     title:OESTRING(@"RECHARGE")
                                                titleColor:UIColor.whiteColor
                                                 titleFont:15
                                              cornerRadius:18
                                           backgroundColor:OE_LIMITE_COLOR
                                           backgroundImage:nil
                                                     image:nil];
    rechageButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    rechageButton.centerY = moneyLable.centerY;
    rechageButton.right = imageView.width - 15;
    [imageView addSubview:rechageButton];
    [rechageButton setClicAction:^(UIButton *sender) {
        [weakSelf.navigationController pushViewController:OERechargeViewController.new animated:YES];
    }];
    header.height = imageView.bottom   + 20;
    self.tableView.tableHeaderView = header;
    
    STButton * deButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 19)
                                                     title:OESTRING(@"Rerurn the deposit money  ")
                                                titleColor:SecendTextColor
                                                 titleFont:15
                                              cornerRadius:0
                                           backgroundColor:nil
                                           backgroundImage:nil
                                                     image:[UIImage imageNamed:@"18×30箭头"]];
    deButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    deButton.top = TMUtils.tabBarTop;
    [deButton makeImageRight];
    [self.view addSubview:deButton];
    [deButton setClicAction:^(UIButton *sender) {
//        [weakSelf.navigationController pushViewController:OERechargeDepositViewController.new animated:YES];
        //去退押金
         [weakSelf.navigationController pushViewController:OEBankListViewController.new animated:YES];
        return ;
        if (weakSelf.money.integerValue < 1) {
            [weakSelf st_showAlertTitle:@"The amount is too small to withdraw cash" message:@"" andWithBlock:^(NSString *name) {
                
            }];
        }else{
            [weakSelf.navigationController pushViewController:OEBankListViewController.new animated:YES];
        }
    }];
}
#pragma mark --Action Method
- (void)st_rightBarAction:(id)sender{
    [self.navigationController pushViewController:OETransactionDetailViewController.new animated:YES];
}

@end
